package com.neusoft.ysu.populationmanagement.controller;

import com.neusoft.ysu.populationmanagement.constant.Errors;
import com.neusoft.ysu.populationmanagement.entity.CommonResult;
import com.neusoft.ysu.populationmanagement.entity.OperationLog;
import com.neusoft.ysu.populationmanagement.service.IVImpPopService;
import com.neusoft.ysu.populationmanagement.vo.VImpPop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/v-imp-pop")
@CrossOrigin
public class VImpPopController {
    @Autowired
    IVImpPopService vImpPopService;

    /**
     * @param vImpPop
     * @param log
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     * @author 赵子鉴
     * @description 采集重点人口信息
     * @date 2024-06-21 15:23
     */
    @RequestMapping("/insert")
    public CommonResult insert(VImpPop vImpPop, OperationLog log) {
//        System.out.println(vImpPop);
        return vImpPopService.insertVImp(vImpPop, log);
    }

    /**
     * @param vImpPop
     * @param log
     * @return CommonResult
     * @author zzj
     * @date 2024-06-19 14:36
     * @description 更新重点人口信息
     */
    @RequestMapping("/update")
    public CommonResult update(VImpPop vImpPop, OperationLog log) {
        return vImpPopService.updateVImp(vImpPop, log);
    }

    /**
     * @param vImpPop
     * @param log
     * @return CommonResult
     * @author zzj
     * @date 2024-06-19 14:36
     * @description 重点人口注销（更改is_delete）
     */
    @RequestMapping("/delete")
    public CommonResult delete(VImpPop vImpPop, OperationLog log) {
        return vImpPopService.deleteVImp(vImpPop, log);
    }

    @RequestMapping("/selectByIdNum")
    public CommonResult selectByIdNum(String idnum) {
        return vImpPopService.selectImpByIdNum(idnum);
    }
    @RequestMapping("/selectChose")
    public CommonResult selectChose(Integer option) {
        return vImpPopService.selectChose(option);
    }
    /**
     * @author 赵子鉴
     * @描述 公安干警递交申请
     * @date 2024-06-22 11:20
     * @param VImpPop
     * @param log
     * @return com.neusoft.ysu.populationmanagement.entity.CommonResult
     */
    @RequestMapping("/send")
    public CommonResult send(VImpPop VImpPop, OperationLog log) {
        return vImpPopService.sendApplication(VImpPop, log);
    }

    @RequestMapping("/checkPass")
    public CommonResult checkPass(VImpPop VImpPop, OperationLog log) {
        return vImpPopService.checkApplication(VImpPop, log, Errors.SUCCESS);
    }
    @RequestMapping("/checkFail")
    public CommonResult checkFail(VImpPop VImpPop, OperationLog log) {
        return vImpPopService.checkApplication(VImpPop, log,Errors.ERROR);
    }

    @RequestMapping("/finalPass")
    public CommonResult finalPass(VImpPop VImpPop, OperationLog log) {
        return vImpPopService.finalApplication(VImpPop, log, Errors.SUCCESS);
    }
    @RequestMapping("/finalFail")
    public CommonResult finalFail(VImpPop VImpPop, OperationLog log) {
        return vImpPopService.finalApplication(VImpPop,log,Errors.ERROR);
    }
}
